package exam.test;

import java.util.Objects;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Administrator
 * Date: 2020-06-15
 * Time: 22:55
 */
public class ClubMember {

    private String name;
    private int age;
    private double membershipFee;

    public ClubMember(String name, int age, double membershipFee) {
        if (name != null) {
            this.name = name;
        } else {
            this.name = "";
        }

        this.age = Math.max(age, 18);

        if (membershipFee == 50 || membershipFee == 100) {
            this.membershipFee = membershipFee;
        } else {
            this.membershipFee = 50;
        }
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ClubMember that = (ClubMember) o;
        return age == that.age &&
                Double.compare(that.membershipFee, membershipFee) == 0 &&
                Objects.equals(name, that.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age, membershipFee);
    }
}
